package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.TravellingExpense;
import com.xx.pmis.persistence.dao.TravellingExpenseDAO;
import com.xx.pmis.services.TravellingExpenseService;

public class TravellingExpenseServiceImpl implements TravellingExpenseService {
	TravellingExpenseDAO travellingExpenseDAO = null;

	public TravellingExpenseServiceImpl(TravellingExpenseDAO travellingExpenseDAO) {
		super();
		this.travellingExpenseDAO = travellingExpenseDAO;
	}

	public void saveOrUpdateTravellingExpense(TravellingExpense travellingExpense) throws Exception {
		travellingExpenseDAO.saveOrUpdate(travellingExpense);
	}

	public void saveTravellingExpense(TravellingExpense travellingExpense) throws Exception {
		travellingExpenseDAO.save(travellingExpense);
	}

	public void deleteTravellingExpense(TravellingExpense travellingExpense) throws Exception {
		travellingExpenseDAO.delete(travellingExpense);
	}

	public TravellingExpense getTravellingExpenseByTravellingExpenseID(String TravellingExpenseID) throws Exception {
		TravellingExpense travellingExpense = travellingExpenseDAO.getTravellingExpenseByTravellingExpenseID(TravellingExpenseID);
		return travellingExpense;
	}

	public List<TravellingExpense> getAllTravellingExpenseByCondition(String sql) throws Exception {
		List<TravellingExpense> travellingExpenses = travellingExpenseDAO.getAllTravellingExpenseByCondition(sql);
		return travellingExpenses;
	}

	public List<TravellingExpense> getAllTravellingExpenseByConditionByPage(String sql, int currentPage, int lineSize) throws Exception {
		List<TravellingExpense> travellingExpenses = travellingExpenseDAO.getAllTravellingExpenseByConditionByPage(sql, currentPage, lineSize);
		return travellingExpenses;
	}

	public int getCountOfTravellingExpenseByCondition(String sql) throws Exception {
		return travellingExpenseDAO.getAllTravellingExpenseByCondition(sql).size();
	}

}
